#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
ExtractToMarkdown 安装配置
作者: Solming
"""

from setuptools import setup, find_packages
import os

# 获取长描述
def get_long_description():
    """读取README文件作为长描述"""
    here = os.path.abspath(os.path.dirname(__file__))
    with open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
        return f.read()

# 获取requirements
def get_requirements():
    """读取requirements文件"""
    requirements_path = os.path.join('converter_engine', 'requirements.txt')
    if os.path.exists(requirements_path):
        with open(requirements_path, encoding='utf-8') as f:
            return [line.strip() for line in f if line.strip() and not line.startswith('#')]
    return []

setup(
    # 基本信息
    name="extract-to-markdown",
    version="1.0.0",
    author="Solming",
    author_email="",  # 仅通过GitHub联系
    description="一个功能强大的文档转换工具，支持多种格式转换为高质量的Markdown（业余项目，维护有限）",
    long_description=get_long_description(),
    long_description_content_type="text/markdown",
    
    # 项目链接
    url="https://github.com/Solming/extractToMarkdown",
    project_urls={
        "Bug Reports": "https://github.com/Solming/extractToMarkdown/issues",
        "Source": "https://github.com/Solming/extractToMarkdown",
        "Documentation": "https://github.com/Solming/extractToMarkdown/blob/main/README.md",
    },
    
    # 包配置
    packages=find_packages(),
    include_package_data=True,
    
    # Python版本要求
    python_requires=">=3.8",
    
    # 依赖
    install_requires=get_requirements(),
    
    # 可选依赖
    extras_require={
        'pdf': [
            'marker-pdf>=0.2.0',
            'docling>=1.0.0',
            'mineru>=0.1.0',
        ],
        'ocr': [
            'paddleocr>=2.7.0',
            'easyocr>=1.7.0',
            'pytesseract>=0.3.10',
        ],
        'office': [
            'pandoc>=2.0.0',
            'python-docx>=0.8.11',
            'python-pptx>=0.6.21',
        ],
        'cloud': [
            'huaweicloudsdkobs>=3.23.0',
        ],
        'dev': [
            'pytest>=7.0.0',
            'pytest-asyncio>=0.21.0',
            'black>=22.0.0',
            'flake8>=5.0.0',
            'isort>=5.10.0',
        ],
        'all': [
            # 包含所有可选依赖
            'marker-pdf>=0.2.0',
            'docling>=1.0.0',
            'mineru>=0.1.0',
            'paddleocr>=2.7.0',
            'easyocr>=1.7.0',
            'pytesseract>=0.3.10',
            'pandoc>=2.0.0',
            'python-docx>=0.8.11',
            'python-pptx>=0.6.21',
            'huaweicloudsdkobs>=3.23.0',
        ]
    },
    
    # 分类
    classifiers=[
        "Development Status :: 5 - Production/Stable",
        "Intended Audience :: Developers",
        "Intended Audience :: End Users/Desktop",
        "Topic :: Office/Business :: Office Suites",
        "Topic :: Text Processing :: Markup",
        "Topic :: Software Development :: Libraries :: Python Modules",
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Programming Language :: Python :: 3.12",
        "Operating System :: OS Independent",
        "Natural Language :: Chinese (Simplified)",
        "Environment :: Console",
    ],
    
    # 关键词
    keywords="document conversion markdown pdf docx ppt ocr",
    
    # 入口点
    entry_points={
        'console_scripts': [
            'extract-to-md=converter_engine.core:main',
        ],
    },
    
    # 数据文件
    package_data={
        'converter_engine': ['requirements.txt', 'USAGE_GUIDE.md'],
    },
    
    # 许可证
    license="MIT",
    
    # 平台
    platforms=["any"],
    
    # ZIP安全
    zip_safe=False,
) 